-use std::os::{getcwd};
+use std::os;
use util::{CargoResult, CliError, CliResult, human};
/// Iteratively search for `file` in `pwd` and its parents, returning
pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
match manifest_path {
Some(path) => Ok(Path::new(path)),
- None => match find_project_manifest(&getcwd(), "Cargo.toml") {
- Ok(x) => Ok(x),
- Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
- directory or any parent directory", 102))
- }
- }
+ None => match find_project_manifest(&os::getcwd(), "Cargo.toml") {
+ Ok(x) => Ok(x),
+ Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
+ directory or any parent directory", 102))
+ }
+ }.map(|path| os::make_absolute(&path))
}
/// Return the path to the `file` in `pwd`, if it exists.
execs().with_stdout("i am foo\n"));
})
+test!(cargo_compile_manifest_path {
+ let p = project("foo")
+ .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
+ .file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
+
+ assert_that(p.cargo_process("cargo-build")
+ .arg("--manifest-path").arg("foo/Cargo.toml")
+ .cwd(p.root().dir_path()),
+ execs().with_status(0));
+ assert_that(&p.bin("foo"), existing_file());
+})
+
test!(cargo_compile_with_invalid_manifest {
let p = project("foo")
.file("Cargo.toml", "");